<?php
  session_start();

  if(!isset($_SESSION['isLogged'])){
    header('Location: index.php');
  }
  $now=time();
  if(isset($_SESSION['isLogged']) && ($now>$_SESSION['expired'])){
    session_unset();
    session_destroy();
    header('Location: index.php');
  }

?>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="clear_input_usulan()">&times;</button>
                <h4 class="modal-title" id="judul_modal">Daftar Usulan</h4>
            </div>
            <div id="modale" class="modal-body" style="margin-left: 16%;">
                <form role="form" id="rekam_frm" method="post">
                    <input type="hidden" class="form-control" id="id_usulan">
                    <div class="form-group">
                        <label for="nomer">No Surat</label>
                        <input type="text" class="form-control" id="no_surat" placeholder="Masukkan Nomer Surat">
                    </div>
                    <div class="form-group">
                        <label for="tgl">Tanggal Surat</label>
                        <div class="controls">
                            <div class="input-group">
                                <input id="tgl_surat" type="text" class="date-picker form-control" />
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="nip">Perihal Surat</label>
                        <textarea class="form-control" rows="3" id="perihal_surat"></textarea>
                    </div>
                    <button type="submit" class="btn btn-default" data-dismiss="modal" onclick="getAllUsulan()">Batal</button>
                    <button type="submit" class="btn btn-default" id="btn_simpan_usulan">Simpan</button>
                    <button type="submit" class="btn btn-default" id="btn_simpan_ubah_usulan">Simpan Perubahan</button>
                </form>
            </div>
            <div id="modale2" class="modal-body">
                <table cellpadding="0" cellspacing="0" border="0" class="datatable table table-condensed table-bordered col-lg-offset-0" id="list_pegawai">
                    <thead>
                        <tr>
                            <th>NIP</th>
                            <th>Nama</th>
                            <th>Jenis Cuti</th>
                            <th>Jenis Ijin</th>
                            <th>Tanggal Cuti</th>
                            <th>Status</th>
                            <th>Hapus</th>
                            <th>Ubah</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
                <a data-toggle="modal" class="btn btn-primary btn-sm navbar-left" href="#myModalInsertPegawai" id="btn_tambah_pegawai">Tambah Pegawai</a>
            </div>
            <div class="modal-footer" id="btn_group_peg">
                <button type="submit" class="btn btn-danger" data-dismiss="modal" onclick="getAllUsulan()">Tutup</button>
                <div id="error" class="alert alert-danger">...</div>
                <div id="success" class="alert alert-success">...</div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="panel panel-primary">
    <div class="panel-heading">
        <h3>Daftar Usulan</h3>
    </div>
    <div class="panel-body">

        <table cellpadding="0" cellspacing="0" border="0" class="datatable table table-condensed table-bordered table-hover col-lg-offset-0" id="list_usulan">
            <thead>
                <tr>
                    <th>No Surat</th>
                    <th>Tanggal Surat</th>
                    <th>Jumlah Pegawai</th>
                    <th>Dokumen</th>
                    <th>Hapus</th>
                    <th>Ubah</th>
                    <th>List Pegawai</th>
                    <th>Kirim</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <a data-toggle="modal" href="#myModal" class="btn btn-primary btn-sm navbar-left" onclick="clear_input_usulan()">Buat Usulan</a>
        <div id="error" class="alert alert-danger">...</div>
        <div id="success" class="alert alert-success">...</div>
    </div>
</div>
<div id="error2" class="alert alert-danger">...</div>
 <div id="success2" class="alert alert-success">...</div>

<div class="modal fade" id="myModalUpload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Upload Dokumen</h4>
            </div>
            <div class="modal-body">
                <div id="frm_upload">
                    <form role="form" id="form_upload_dokumen" method="post" enctype="multipart/form-data">
                        <div class="form-group">
                            <input type="hidden" class="form-control"name="id_usulan_upload" id="id_usulan_upload" placeholder="Enter email">
                        </div>
                        <div class="form-group">
                            <label for="inputFile">Judul File</label>
                            <input type="text" id="judulFile" class="form-control" name="judulFile">
                        </div>
                        <div class="form-group">
                            <label for="inputFile">Pilih File</label>
                            <input type="file" id="file_dokumen" class="form-control" name="file_dokumen">
                        </div>
                        <div class="form-group">
                            <input class="btn btn-warning btn-sm" type="submit" id="btn_inputFile" onclick="return ajaxFileUpload();" value="Upload">
                        </div>
                    </form>
                    <div id="error3" class="alert alert-danger">...</div>
                    <div id="success3" class="alert alert-success">...</div>
                </div>
                <div id="list_dokumen">
                    <table id="list_dokumen" cellpadding="0" cellspacing="0" border="0" class="datatable table table-condensed table-bordered col-lg-offset-0">
                        <thead>
                            <tr>
                                <th>No</th>
                                <th>Deskripsi</th>
                                <th colspan="2">Aksi</th>
                            </tr>
                        </thead>
                        <tbody>

                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- <div class="modal fade" id="myModalProses" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Proses Usulan</h4>
            </div>
            <div class="modal-body" style="margin-left: 1%;">
                <table>
                    <tr>
                        <td>
                <table id="list_detail_proses" class="table-condensed table-bordered table-hover">
                    <thead>
                        <th colspan="2" style="text-align: center;">Biodata</th>
                    </thead>
                    <tr>
                        <th>NIP</th>
                        <td id="nip"></td>
                    </tr>
                    <tr>
                        <th>Nama</th>
                        <td id="nama"></td>
                    </tr>
                    <tr>
                        <th>Golongan</th>
                        <td id="gol"></td>
                    </tr>
                    <tr>
                        <th>Jabatan</th>
                        <td id="eselon"></td>
                    </tr>
                    <thead>
                        <th colspan="2" style="text-align: center;">Detail Ijin</th>
                    </thead>
                    <tr>
                        <th>Tujuan</th>
                        <td id="id_tujuan"></td>
                    </tr>
                    <tr>
                        <th>Jenis Cuti</th>
                        <td id="id_cuti"></td>
                    </tr>
                    <tr>
                        <th>Tgl Cuti</th>
                        <td id="tgl"></td>
                    </tr>
                    <thead>
                        <th colspan="2" style="text-align: center;">Dokumen</th>
                    </thead>
                    <tr>
                        <td colspan="2">Filenya</td>
                    </tr>
                </table>
                </td>
                <td>
                <table class="table-condensed table-bordered" id="form_proses">
                    <thead>
                    <th colspan="3">Proses</th>
                    </thead>
                    <tbody>
                    <form role="form" method="post">
                        <input type="hidden" id="id_detail">
                        <tr>
                            <th>Persetujuan</th>
                            <td colspan="2" >
                                <select id="persetujuan" class="form-control">
                                    <option value="1">Ditolak</option>
                                    <option value="2">Konfirmasi</option>
                                    <option value="3">Terima</option>
                                    <option value="4">Dalam Proses</option>
                                    <option value="5">Disetujui</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>Upload Surat</th>
                            <td colspan="2"><input type="file" class="form-control" id="file_surat" name="file_surat"/></td>
                        </tr>
                        <tr>
                            <th>Deskripsi Konfirmasi / Alasan Penolakan</th>
                            <td colspan="2"><textarea rows="3" class="form-control" id="alasan"/></textarea></td>
                        </tr>
                        <tr>
                            <td colspan="2"><button type="button" class="btn btn-primary btn-sm" id="btn_proses" onclick="ajaxProsesUpload()">Proses</button></td>
                        </tr>
                    </form>
                    </tbody>
                </table>
            </td>
        </tr>
    </table>
    <div id="error6" class="alert alert-danger">...</div>
    <div id="success6" class="alert alert-success">...</div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
     </div>
</div>/.modal  -->


<div class="modal fade" id="myModalInsertPegawai" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Rekam / Ubah Pegawai</h4>
            </div>
            <div class="modal-body">
                <table class="table table-condensed table-bordered">
                    <form role="form" class="form-horizontal" id="tambah_peg_frm" method="post">
                        <input type="hidden" class="form-control" id="id_usulan_peg">
                        <input type="hidden" class="form-control" id="id_det_usulan">
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="nomer">NIP</label>
                            </td>
                            <td width="85">
                            <input type="text" class="form-control" id="nip_peg" placeholder="Masukkan NIP">
                        </div>
                        </td>
                        </tr>
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="level">Jenis Cuti</label>
                            </td>
                            <td width="85">
                            <select class="form-control" id="id_cuti_peg">
                                
                            </select>
                        </div>
                        </td>
                        </tr>
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="level">Jenis Ijin</label>
                            </td>
                            <td width="85">
                            <select class="form-control" id="id_tujuan_peg">
                                <option value="1">Ibadah</option>
                                <option value="2">Berobat</option>
                                <option value="3">Wisata</option>
                                <option value="4">Dinas</option>
                                <option value="5">Lain-lain</option>
                            </select>
                        </div>
                        </td>
                        </tr>
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="tgl">Tgl Mulai</label>
                            </td>
                            <td width="85">
                            <div class="controls">
                                <div class="input-group">
                                    <input id="tgl_mulai" type="text" class="date-picker form-control" />
                                    </label>
                                </div>
                            </div>
                        </div>
                        </td>
                        </tr>
                        <tr>
                            <td width="35">
                        <div class="form-group">
                            <label for="tgl">Tgl Selesai</label>
                            </td>
                            <td width="85">
                            <div class="controls">
                                <div class="input-group">
                                    <input id="tgl_selesai" type="text" class="date-picker form-control" />
                                    </label>
                                </div>
                            </div>
                        </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                        <a data-toggle="modal" type="submit" class="btn btn-warning btn-sm" onclick="clear_input_peg()">Batal</a>
                        <button type="submit" class="btn btn-primary btn-sm" id="btn_simpan_peg">Simpan</button>   
                        <button type="submit" class="btn btn-primary btn-sm" id="btn_simpan_ubah_peg" style="display: none;">Simpan</button>
                            </td>
                        </tr>
                    </form>
                    </table>
                <div id="error5" class="alert alert-danger">Ini</div>
                <div id="success5" class="alert alert-success">Itu</div>
                <div id="biodata" style="float:right; display: none;">
                    <table id="data_pegawai" class="table-condensed table-bordered table-hover">
                        <thead>
                        <th colspan="2" style="text-align: center;">Biodata</th>
                        </thead>
                        <tr>
                            <th>NIP</th>
                            <td id="nip_td"></td>
                        </tr>
                        <tr>
                            <th>Nama</th>
                            <td id="nama_td"></td>
                        </tr>
                        <tr>
                            <th>Golongan</th>
                            <td id="gol_td"></td>
                        </tr>
                        <tr>
                            <th>Jabatan</th>
                            <td id="eselon_td"></td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<script type="text/javascript" src="js/ajaxfileupload.js"></script>
<script type="text/javascript" src="js/usulan.js" ></script>

<script type="text/javascript">

        

        $(".date-picker").datepicker({
            format: 'yyyy-mm-dd',
            weekStart: 1,
        });

</script>
